package org.example.config;

/**
 * org.example.config
 *
 * @author 莫磊
 * @description
 * @date 2025/7/25
 */


import com.fasterxml.jackson.databind.ObjectMapper;
import org.example.entity.Outbound;
import org.example.entity.ConfigSpeedtest;
import org.example.entity.Server;

import java.io.File;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

public class ConfigLoader {
	public static List<Server> loadSocksServers(String filePath) throws IOException {
		ObjectMapper mapper = new ObjectMapper();
		ConfigSpeedtest config = mapper.readValue(new File(filePath), ConfigSpeedtest.class);

		List<Server> socksServers = new ArrayList<>();

		for (Outbound outbound : config.getOutbounds()) {
			if (outbound.getSettings() != null && outbound.getSettings().getServers() != null) {
				socksServers.addAll(outbound.getSettings().getServers());
			}
		}

		return socksServers;
	}
}